<template>
	<view class="Jy_account_page">
		<view class="Jy_account_container">
			<view class="account_text_login_box">
				<text>账号密码登录</text>
			</view>
			<view class="phone_group">
				<view class="text_box">
					<text>手机号</text>
				</view>
				<view class="input_box">
					<input type="number" placeholder="手机号" v-model="account.account" maxlength="11">
				</view>
			</view>
			<view class="password_group">
				<view class="text_box">
					<text>密码</text>
				</view>
				<view class="input_box">
					<input type="password" placeholder="密码" v-model="account.password">
				</view>
			</view>
			<view class="login_button_box" @click="logion">
				<text>登录</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				account: {
					account: '',
					password: ''
				}
			};
		},
		onLoad() {
			if(uni.getStorageSync("yljjUserInfo")){
				uni.switchTab({
					url:'../../../../pages/main/customerHome/customerHome'
				})
			}
		},
		methods: {
			// 跳转到售后详情
			logion() {
				
				this.sendRequest({
					url: "/api/front/login",
					data: this.account,
					method: 'post',
					success: res => {
						if (res.data.data.token) {
							uni.setStorageSync("yljjToken", res.data.data.token)
							this.getuserInfo()

						}
					}
				})
			},
			getuserInfo() {
				this.sendRequest({
					url: "/api/front/user",
					// data: data,
					success: res => {
						if (res.data.data) {
							uni.setStorageSync("yljjUserInfo", res.data.data)
							uni.switchTab({
								url:'../../../../pages/main/customerHome/customerHome'
							})
						}
					}
				})
			},
		}

	}
</script>

<style lang="scss" scoped>
	@import 'accountLogin.scss';
</style>
